Repository navigation
trace: skip JSON lines that are not objects in the cursor readers - #181
Aaron Li (aaron-jx-li) merged 1 commit into
Conversation
cursor_events_to_claude and the prompt-count spool loop called .get on whatever json.loads returned, so one line that parses but is not an object (null, 42, "text", [1, 2]) raised AttributeError and discarded the whole session's trace. microsoft#150 added the isinstance check to the other 13 readers; the cursor pair from microsoft#149 was not in that sweep. Add the same guard, with a regression test. Fixes microsoft#180 Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>
Aaron Li (aaron-jx-li)
left a comment
There was a problem hiding this comment.
Rahul (@rahul05ranjan) Thanks! The code looks correct, but please sign the agreement so we can merge your code.
|
Thanks Aaron Li (@aaron-jx-li) — the license/cla check is now passing on the current head (agreement signed), with the rest of the CI matrix green. Should be ready for re-review whenever you have a moment. |
|
Thank you for the merge! Both readers now skip non-object JSON lines consistently. On a personal note — I'm currently open to new opportunities (Full Stack (PHP, NodeJs, Python) / Data Science / Applied AI / Devtools, based in India). If there's an opening or referral you'd recommend, my inbox is open: |
Fixes #180.
cursor_events_to_claudeand the prompt-count spool loop called.geton whateverjson.loadsreturned, so a line that parses but is not an object (null,42,"text",[1, 2]) raisedAttributeErrorand discarded the whole session's trace — the same failure shape #150 fixed for the other 13 readers, missed here because the cursor pair came with the #149 headless work.The change is the same one-line
isinstance(event, dict)guard afterjson.loads, in both loops. The prompt-count fallback over Cursor's own transcript already had the guard; the spool loop andcursor_events_to_claudedid not.Verification
test_cursor_readers_skip_json_lines_that_are_not_objects: a spool withnull,[1, 2],"str",42lines around aUserPromptSubmitand aPostToolUse— fails on main@264e7a7 withAttributeErroratcursor.py:96, passes with the fix: the count and the reconstructed trace keep exactly the valid records.python3 -m pytest tests/ -q) green with the fix; standard library only, no dependencies.